package com.oweight.sagacious.payment.infrastructure.interceptor;

import com.oweight.sagacious.auth.client.config.UserAuthConfig;
import com.oweight.sagacious.common.context.BaseContextHandler;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 周广明
 * @version v1 2019/11/1 18:51
 */
public class ClientTokenInterceptor implements RequestInterceptor {

    @Autowired
    private UserAuthConfig userAuthConfig;

    @Override
    public void apply(RequestTemplate requestTemplate) {
        try {
            requestTemplate.header(userAuthConfig.getTokenHeader(), BaseContextHandler.getToken());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
